]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
theme-node: Fix box-shadows for prerendered textures
authorFlorian Müllner <fmuellner@gnome.org>
Fri, 4 Feb 2011 00:45:16 +0000 (01:45 +0100)
committerFlorian Müllner <fmuellner@gnome.org>
Mon, 7 Feb 2011 17:22:33 +0000 (18:22 +0100)
The material of prerendered backgrounds is now painted in the
rectangle determined by st_theme_node_get_paint_box(). As the
ClutterActorBox returned from that function includes the space
needed to draw the box shadow, the background ends up occluding
the shadow.
As the box shadow is not part of the background, factor out a new
helper function which excludes the box shadow, and use it to
prerender and place the background material.

https://bugzilla.gnome.org/show_bug.cgi?id=641522

src/st/st-theme-node-drawing.c
src/st/st-theme-node.c
src/st/st-theme-node.h

index 52c737ef4fe3be656fcf81a93166cbe454ae2f46..409fbd4692f6c9b3eef2f9b5ccc6ecc335c0c75b 100644 (file)
@@ -748,7 +748,7 @@ st_theme_node_render_background_with_border (StThemeNode *node)
    * may need to create an image bigger than the nodes
    * allocation
    */
-  st_theme_node_get_paint_box (node, &actor_box, &paint_box);
+  st_theme_node_get_background_paint_box (node, &actor_box, &paint_box);
 
   /* translate the boxes so the paint box is at 0,0
   */
@@ -1691,7 +1691,9 @@ st_theme_node_paint (StThemeNode           *node,
         {
           ClutterActorBox paint_box;
 
-          st_theme_node_get_paint_box (node, &allocation, &paint_box);
+          st_theme_node_get_background_paint_box (node,
+                                                  &allocation,
+                                                  &paint_box);
 
           paint_material_with_opacity (node->prerendered_material,
                                        &paint_box,
index b57afb654792cc2b0ef0482f48504692c16bd9c2..6fb579f095e14d0407318ab3eb50cbdd02a281d0 100644 (file)
@@ -3225,6 +3225,42 @@ st_theme_node_get_content_box (StThemeNode           *node,
   content_box->y2 = (int)(0.5 + content_box->y1 + content_height);
 }
 
+/**
+ * st_theme_node_get_background_paint_box:
+ * @node: a #StThemeNode
+ * @allocation: the box allocated to a #ClutterActor
+ * @paint_box: computed box occupied when painting the actor's background
+ *
+ * Gets the box used to paint the actor's background, including the area
+ * occupied by properties which paint outside the actor's assigned allocation.
+ */
+void
+st_theme_node_get_background_paint_box (StThemeNode           *node,
+                                        const ClutterActorBox *actor_box,
+                                        ClutterActorBox       *paint_box)
+{
+  StShadow *background_image_shadow;
+  ClutterActorBox shadow_box;
+
+  g_return_if_fail (ST_IS_THEME_NODE (node));
+  g_return_if_fail (actor_box != NULL);
+  g_return_if_fail (paint_box != NULL);
+
+  background_image_shadow = st_theme_node_get_background_image_shadow (node);
+
+  *paint_box = *actor_box;
+
+  if (!background_image_shadow)
+    return;
+
+  st_shadow_get_box (background_image_shadow, actor_box, &shadow_box);
+
+  paint_box->x1 = MIN (paint_box->x1, shadow_box.x1);
+  paint_box->x2 = MAX (paint_box->x2, shadow_box.x2);
+  paint_box->y1 = MIN (paint_box->y1, shadow_box.y1);
+  paint_box->y2 = MAX (paint_box->y2, shadow_box.y2);
+}
+
 /**
  * st_theme_node_get_paint_box:
  * @node: a #StThemeNode
@@ -3242,7 +3278,6 @@ st_theme_node_get_paint_box (StThemeNode           *node,
                              ClutterActorBox       *paint_box)
 {
   StShadow *box_shadow;
-  StShadow *background_image_shadow;
   ClutterActorBox shadow_box;
   int outline_width;
 
@@ -3251,12 +3286,11 @@ st_theme_node_get_paint_box (StThemeNode           *node,
   g_return_if_fail (paint_box != NULL);
 
   box_shadow = st_theme_node_get_box_shadow (node);
-  background_image_shadow = st_theme_node_get_background_image_shadow (node);
   outline_width = st_theme_node_get_outline_width (node);
 
-  *paint_box = *actor_box;
+  st_theme_node_get_background_paint_box (node, actor_box, paint_box);
 
-  if (!box_shadow && !background_image_shadow && !outline_width)
+  if (!box_shadow && !outline_width)
     return;
 
   paint_box->x1 -= outline_width;
@@ -3268,16 +3302,6 @@ st_theme_node_get_paint_box (StThemeNode           *node,
     {
       st_shadow_get_box (box_shadow, actor_box, &shadow_box);
 
-      paint_box->x1 = MIN (paint_box->x1, shadow_box.x1);
-      paint_box->x2 = MAX (paint_box->x2, shadow_box.x2);
-      paint_box->y1 = MIN (paint_box->y1, shadow_box.y1);
-      paint_box->y2 = MAX (paint_box->y2, shadow_box.y2);
-    }
-
-  if (background_image_shadow)
-    {
-      st_shadow_get_box (background_image_shadow, actor_box, &shadow_box);
-
       paint_box->x1 = MIN (paint_box->x1, shadow_box.x1);
       paint_box->x2 = MAX (paint_box->x2, shadow_box.x2);
       paint_box->y1 = MIN (paint_box->y1, shadow_box.y1);
index ad9e4e097b93cc47bea925d374fcf2b1347d6e73..46d38b6aa8b8c5c86c7efede15ec25f02a289641 100644 (file)
@@ -228,6 +228,10 @@ void st_theme_node_get_content_box         (StThemeNode        *node,
 void st_theme_node_get_paint_box           (StThemeNode           *node,
                                             const ClutterActorBox *allocation,
                                             ClutterActorBox       *paint_box);
+/* Helper for background prerendering */
+void st_theme_node_get_background_paint_box (StThemeNode           *node,
+                                             const ClutterActorBox *allocation,
+                                             ClutterActorBox       *paint_box);
 
 gboolean st_theme_node_geometry_equal (StThemeNode *node,
                                        StThemeNode *other);